package visitorPattern;

import java.util.ArrayList;
import java.util.List;

//文本结构
public class Document {

    private List<Element> elements;

    public Document() {
        this.elements = new ArrayList<>();
    }

    public Document(List<Element> elements) {
        this.elements = elements;
    }

    public void addElement(Element element) {
        this.elements.add(element);
    }

    public void accept(Visitor visitor) {
        for (Element element : elements) {
            element.accept(visitor);
        }
    }

}
